<template>
  <div>
    <div class="fans">
      <div class="title">
        <i class="iconfont icon-xiangzuo" @click="$router.go(-1)"></i>
        <p>本书粉丝排行</p>
      </div>

      <div class="fansContent">
        <div class="fansHead">
          <div class="img">
            <img :src="userInfo.img" />
          </div>
          <div class="fansHeadCon">
            <div class="fanstop">
              <div class="left">
                <h1>{{ userInfo.fens }}</h1>
                <span>我的粉丝值</span>
              </div>
              <div class="right">
                <p>未上榜</p>
                <span>我的排名</span>
              </div>
            </div>
            <div class="fansbtm">努力投票打赏，争取上榜哦</div>
          </div>
        </div>

        <ul>
          <van-list
            v-model="loading"
            :finished="finished"
            finished-text="没有更多了"
            @load="onLoad"
          >
            <li
              v-for="(item, index) in fens"
              :key="index"
              :class="{ frist: index == 0, two: index == 1, three: index == 2 }"
            >
              <div
                class="iconfont icon-huangguan"
                v-show="false == index > 3"
              ></div>
              <div class="num" v-show="true == index > 3">{{ index + 1 }}</div>
              <div class="img">
                <img :src="item.img" />
              </div>
              <div class="fansNum">
                <h1>{{ item.name }}</h1>
                <p>
                  本书粉丝值<span>{{ item.fensNums }}</span>
                </p>
              </div>
            </li>

            <!-- <li class="two">
              <div class="iconfont icon-huangguan"></div>

              <div class="img">
                <img
                  src="//bossaudioandcomic-1252317822.image.myqcloud.com/activity/document/4b59c747dca1e5a532696d1fd7b54052.jpg"
                />
              </div>
              <div class="fansNum">
                <h1>蜜橘</h1>
                <p>本书粉丝值<span>20</span></p>
              </div>
            </li>

            <li class="three">
              <div class="iconfont icon-huangguan"></div>

              <div class="img">
                <img
                  src="//bossaudioandcomic-1252317822.image.myqcloud.com/activity/document/4b59c747dca1e5a532696d1fd7b54052.jpg"
                />
              </div>
              <div class="fansNum">
                <h1>蜜橘</h1>
                <p>本书粉丝值<span>20</span></p>
              </div>
            </li>

            <li>
              <div class="num">4</div>

              <div class="img">
                <img
                  src="//bossaudioandcomic-1252317822.image.myqcloud.com/activity/document/4b59c747dca1e5a532696d1fd7b54052.jpg"
                />
              </div>
              <div class="fansNum">
                <h1>蜜橘</h1>
                <p>本书粉丝值<span>20</span></p>
              </div>
            </li> -->
          </van-list>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import { getFensRank } from "../../api/content";
import { getUsersInfo } from "../../api/userInfo";
export default {
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      fens: [],
      userInfo: [],
    };
  },
  methods: {
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        for (let i = 0; i < 10; i++) {
          this.list.push(this.list.length + 1);
        }

        // 加载状态结束
        this.loading = false;

        // 数据全部加载完成
        if (this.list.length >= 40) {
          this.finished = true;
        }
      }, 1000);
    },
  },
  created() {
    this.$emit("getnavs-btn", false);
    getUsersInfo().then((data) => {
      this.userInfo = data;
    });
    getFensRank().then((data) => {
      this.fens = data.fens;
    });
  },
};
</script>

<style lang="less">
.fans {
  //   background-color: #fff;

  .title {
    position: fixed;
    width: 100%;
    min-height: 50px;
    display: flex;
    background-color: #fff;
    line-height: 50px;
    text-align: center;
    font-size: 20px;
    i {
      flex: 0 0 40px;
      font-size: 25px;
    }
    p {
      flex: 1;
      margin-right: 30px;
    }
  }
  .fansContent {
    padding-top: 40px;
    .fansHead {
      background-color: #fff;
      padding: 25px;
      display: flex;
      .img {
        width: 70px;
        height: 90px;
        border-radius: 4px;
        margin-right: 35px;
        img {
          width: 70px;
          height: 90px;
          border-radius: 4px;
        }
      }
      .fansHeadCon {
        flex: 1;
        .fanstop {
          display: flex;
          align-items: baseline;
          padding-top: 10px;
          .left,
          .right {
            width: 50%;
            h1 {
              font-size: 16px;
            }
            p {
              font-size: 13px;
            }
            span {
              display: block;
              padding: 10px 0;
              font-size: 12px;
              color: #969799;
            }
          }
        }
        .fansbtm {
          margin-top: 4px;
          color: #969799;
          font-size: 14px;
        }
      }
    }
    ul {
      margin-top: 4px;
      li {
        padding: 15px 25px;
        background-color: #fff;
        display: flex;
        margin-bottom: 1px;
        margin-bottom: 1px;
        .iconfont {
          color: #969799;
          font-size: 25px;
          flex: 0 0 20px;
          line-height: 45px;
          margin-right: 15px;
        }
        .num {
          text-align: center;
          color: #969799;
          font-size: 16px;
          flex: 0 0 20px;
          line-height: 45px;
          margin-right: 15px;
          padding-left: 4px;
        }
        .img {
          border-radius: 50%;
          border: 2px solid transparent;
          padding: 2px;
          margin-right: 15px;
          img {
            width: 40px;
            height: 40px;
            border-radius: 50%;
          }
        }
        .fansNum {
          flex: 1;
          h1 {
            font-size: 14px;
            padding: 8px 0;
          }
          p {
            display: block;
            font-size: 12px;
            color: #969799;
            span {
              margin-left: 20px;
              color: rgb(35, 179, 130);
            }
          }
        }
      }
      .frist {
        .iconfont {
          color: rgb(254, 213, 48);
        }
        .img {
          border-color: rgb(254, 213, 48);
        }
      }
      .two {
        .iconfont {
          color: #c7c8c8;
        }
        .img {
          border-color: #c7c8c8;
        }
      }
      .three {
        .iconfont {
          color: rgb(202, 149, 97);
        }
        .img {
          border-color: rgb(202, 149, 97);
        }
      }
    }
  }
}
</style>